/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AgregarBebe.java
 *
 * Created on 16-ene-2012, 23:24:19
 */
package clienteescritorio;

import Logica.BebeXml;
import Logica.ConsultaXml;
import Logica.UsuarioXml;
import Proxy.Consulta.Consulta;
import Proxy.Usuarios.Usuario;
import Proxy.WsBebe.Bebe;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 *
 * @author familia
 */
public class Operaciones extends javax.swing.JFrame {

    private static List<Bebe> lista;
    private List<Bebe> busqueda;
    private Bebe bebeEditar;
    /** Creates new form AgregarBebe */
    public Operaciones() {
        initComponents();
        this.panelAgregarBebe.setVisible(false);
        this.panelAgregarConsulta.setVisible(false);
        this.panelIngresar.setVisible(true);
        panelPrincipal.removeAll();
        panelPrincipal.add("Inicio Session",panelIngresar);
        lista = obtenerBebes(null);
        this.pacientes.removeAllItems();
        panelListaBusquedaBebe.setVisible(false);
        for(int i = 0; i < lista.size(); i ++){
            pacientes.addItem(lista.get(i).getNombre() + " " + lista.get(i).getApellido());
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelPrincipal = new javax.swing.JTabbedPane();
        panelIngresar = new javax.swing.JPanel();
        login = new javax.swing.JTextField();
        password = new javax.swing.JPasswordField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        panelAgregarConsulta = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        circuferenciaCefalica = new javax.swing.JTextField();
        pesoPaciente = new javax.swing.JTextField();
        estaturaPaciente = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        pacientes = new javax.swing.JComboBox();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        panelAgregarBebe = new javax.swing.JPanel();
        nombreBebe = new javax.swing.JTextField();
        apellidoBebe = new javax.swing.JTextField();
        fechaNacimientoBebe = new javax.swing.JTextField();
        cedulaPapa = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        panelBuscarBebe = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        cedulaBusqueda = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        apellidoBusqueda = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        nombreBusqueda = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        panelListaBusquedaBebe = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaBebe = new javax.swing.JTable();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        panelEditarBebe = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        nombreBebeEditar = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        apellidoBebeEditar = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        fechaNacimientoBebeEditar = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        cedulaPapaEditar = new javax.swing.JTextField();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        panelConsultasBebe = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaReporte = new javax.swing.JTable();
        jLabel18 = new javax.swing.JLabel();
        lbNombrePaciente = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        lbFechaNacimiento = new javax.swing.JLabel();
        jButton11 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        panelPrincipal.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                panelPrincipalStateChanged(evt);
            }
        });
        panelPrincipal.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentMoved(java.awt.event.ComponentEvent evt) {
                panelPrincipalComponentMoved(evt);
            }
        });
        panelPrincipal.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                panelPrincipalFocusGained(evt);
            }
        });

        jLabel1.setText("Login");

        jLabel2.setText("Password");

        jButton1.setText("Ingresar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelIngresarLayout = new javax.swing.GroupLayout(panelIngresar);
        panelIngresar.setLayout(panelIngresarLayout);
        panelIngresarLayout.setHorizontalGroup(
            panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelIngresarLayout.createSequentialGroup()
                .addContainerGap(211, Short.MAX_VALUE)
                .addGroup(panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelIngresarLayout.createSequentialGroup()
                        .addGroup(panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(password, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(login, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
                        .addGap(230, 230, 230))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelIngresarLayout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(304, 304, 304))))
        );
        panelIngresarLayout.setVerticalGroup(
            panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelIngresarLayout.createSequentialGroup()
                .addGap(76, 76, 76)
                .addGroup(panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelIngresarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(241, Short.MAX_VALUE))
        );

        panelPrincipal.addTab("Iniciar Session", panelIngresar);

        panelAgregarConsulta.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                panelAgregarConsultaFocusGained(evt);
            }
        });

        jLabel7.setText("Paciente:");

        jLabel8.setText("Circufenrecia Cefalica:");

        jLabel9.setText("Peso:");

        jLabel10.setText("Estatura:");

        pacientes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton4.setText("Aceptar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Cancelar");

        javax.swing.GroupLayout panelAgregarConsultaLayout = new javax.swing.GroupLayout(panelAgregarConsulta);
        panelAgregarConsulta.setLayout(panelAgregarConsultaLayout);
        panelAgregarConsultaLayout.setHorizontalGroup(
            panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAgregarConsultaLayout.createSequentialGroup()
                .addGap(218, 218, 218)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10))
                .addGap(18, 18, 18)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(estaturaPaciente, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pesoPaciente)
                    .addComponent(pacientes, javax.swing.GroupLayout.Alignment.LEADING, 0, 143, Short.MAX_VALUE)
                    .addComponent(circuferenciaCefalica, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap(213, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelAgregarConsultaLayout.createSequentialGroup()
                .addContainerGap(354, Short.MAX_VALUE)
                .addComponent(jButton4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton5)
                .addGap(194, 194, 194))
        );
        panelAgregarConsultaLayout.setVerticalGroup(
            panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAgregarConsultaLayout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pacientes, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(circuferenciaCefalica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesoPaciente, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(estaturaPaciente, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addGap(27, 27, 27)
                .addGroup(panelAgregarConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jButton5))
                .addContainerGap(196, Short.MAX_VALUE))
        );

        panelPrincipal.addTab("Agregar Consulta", panelAgregarConsulta);

        jLabel3.setText("Nombre:");

        jLabel4.setText("Apellido:");

        jLabel5.setText("Fecha de Nacimiento:");

        jLabel6.setText("Cedula Representante:");

        jButton2.setText("Agregar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Cancelar");

        javax.swing.GroupLayout panelAgregarBebeLayout = new javax.swing.GroupLayout(panelAgregarBebe);
        panelAgregarBebe.setLayout(panelAgregarBebeLayout);
        panelAgregarBebeLayout.setHorizontalGroup(
            panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAgregarBebeLayout.createSequentialGroup()
                .addGap(199, 199, 199)
                .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(cedulaPapa, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(fechaNacimientoBebe, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(apellidoBebe, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nombreBebe, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(238, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelAgregarBebeLayout.createSequentialGroup()
                .addContainerGap(311, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addGap(237, 237, 237))
        );
        panelAgregarBebeLayout.setVerticalGroup(
            panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAgregarBebeLayout.createSequentialGroup()
                .addGap(75, 75, 75)
                .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nombreBebe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(apellidoBebe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(8, 8, 8)
                .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelAgregarBebeLayout.createSequentialGroup()
                        .addComponent(fechaNacimientoBebe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cedulaPapa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)))
                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING))
                .addGap(18, 18, 18)
                .addGroup(panelAgregarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap(188, Short.MAX_VALUE))
        );

        panelPrincipal.addTab("Agregar Bebe", panelAgregarBebe);

        jLabel11.setText("Cedula Representante:");

        jLabel12.setText("Apellido Paciente:");

        jLabel13.setText("Nombre Paciente:");

        jButton6.setText("Buscar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        tablaBebe.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tablaBebe);

        jButton7.setText("Editar");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setText("Consultas");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelListaBusquedaBebeLayout = new javax.swing.GroupLayout(panelListaBusquedaBebe);
        panelListaBusquedaBebe.setLayout(panelListaBusquedaBebeLayout);
        panelListaBusquedaBebeLayout.setHorizontalGroup(
            panelListaBusquedaBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelListaBusquedaBebeLayout.createSequentialGroup()
                .addGroup(panelListaBusquedaBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelListaBusquedaBebeLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton8))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelListaBusquedaBebeLayout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 511, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        panelListaBusquedaBebeLayout.setVerticalGroup(
            panelListaBusquedaBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelListaBusquedaBebeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(panelListaBusquedaBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton8)
                    .addComponent(jButton7))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panelBuscarBebeLayout = new javax.swing.GroupLayout(panelBuscarBebe);
        panelBuscarBebe.setLayout(panelBuscarBebeLayout);
        panelBuscarBebeLayout.setHorizontalGroup(
            panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBuscarBebeLayout.createSequentialGroup()
                .addGroup(panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelBuscarBebeLayout.createSequentialGroup()
                        .addGap(308, 308, 308)
                        .addComponent(jButton6))
                    .addGroup(panelBuscarBebeLayout.createSequentialGroup()
                        .addGap(61, 61, 61)
                        .addGroup(panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel13)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(nombreBusqueda)
                            .addComponent(cedulaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(apellidoBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelBuscarBebeLayout.createSequentialGroup()
                        .addGap(49, 49, 49)
                        .addComponent(panelListaBusquedaBebe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(46, Short.MAX_VALUE))
        );
        panelBuscarBebeLayout.setVerticalGroup(
            panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBuscarBebeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(cedulaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelBuscarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(nombreBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(apellidoBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton6)
                .addGap(35, 35, 35)
                .addComponent(panelListaBusquedaBebe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(89, Short.MAX_VALUE))
        );

        panelPrincipal.addTab("Buscar Bebe", panelBuscarBebe);

        jLabel14.setText("Nombre:");

        jLabel15.setText("Apellido:");

        jLabel16.setText("Fecha de Nacimiento:");

        jLabel17.setText("Cedula Representante:");

        jButton9.setText("Editar");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setText("Cancelar");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelEditarBebeLayout = new javax.swing.GroupLayout(panelEditarBebe);
        panelEditarBebe.setLayout(panelEditarBebeLayout);
        panelEditarBebeLayout.setHorizontalGroup(
            panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEditarBebeLayout.createSequentialGroup()
                .addGap(199, 199, 199)
                .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel17)
                    .addComponent(jLabel16)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(cedulaPapaEditar, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(fechaNacimientoBebeEditar, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(apellidoBebeEditar, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nombreBebeEditar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(238, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelEditarBebeLayout.createSequentialGroup()
                .addContainerGap(321, Short.MAX_VALUE)
                .addComponent(jButton9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton10)
                .addGap(237, 237, 237))
        );
        panelEditarBebeLayout.setVerticalGroup(
            panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEditarBebeLayout.createSequentialGroup()
                .addGap(75, 75, 75)
                .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nombreBebeEditar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(apellidoBebeEditar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addGap(8, 8, 8)
                .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelEditarBebeLayout.createSequentialGroup()
                        .addComponent(fechaNacimientoBebeEditar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cedulaPapaEditar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17)))
                    .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING))
                .addGap(18, 18, 18)
                .addGroup(panelEditarBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton9)
                    .addComponent(jButton10))
                .addContainerGap(188, Short.MAX_VALUE))
        );

        panelPrincipal.addTab("Editar Bebe", panelEditarBebe);

        tablaReporte.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tablaReporte);

        jLabel18.setText("Paciente:");

        lbNombrePaciente.setText("jLabel19");

        jLabel19.setText("Fecha de Nacimiento:");

        lbFechaNacimiento.setText("jLabel20");

        jButton11.setText("Regresar");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelConsultasBebeLayout = new javax.swing.GroupLayout(panelConsultasBebe);
        panelConsultasBebe.setLayout(panelConsultasBebeLayout);
        panelConsultasBebeLayout.setHorizontalGroup(
            panelConsultasBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelConsultasBebeLayout.createSequentialGroup()
                .addGap(206, 206, 206)
                .addGroup(panelConsultasBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel19)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelConsultasBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbNombrePaciente)
                    .addComponent(lbFechaNacimiento))
                .addContainerGap(345, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelConsultasBebeLayout.createSequentialGroup()
                .addContainerGap(32, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 650, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelConsultasBebeLayout.createSequentialGroup()
                .addContainerGap(512, Short.MAX_VALUE)
                .addComponent(jButton11)
                .addGap(111, 111, 111))
        );
        panelConsultasBebeLayout.setVerticalGroup(
            panelConsultasBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelConsultasBebeLayout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addGroup(panelConsultasBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(lbNombrePaciente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelConsultasBebeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(lbFechaNacimiento))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton11)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelPrincipal.addTab("Consultas Paciente", panelConsultasBebe);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 705, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 432, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Metodo que toma el evento click del boton ingresar cuando 
     * se inicia session
     * @param evt 
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        
        Usuario usuario = new Usuario();
        usuario.setLogin(login.getText());
        usuario.setPassword(password.getText());
        if(validarCredenciales(usuario)){
            panelPrincipal.removeAll();
            panelPrincipal.add("Agregar Bebe", panelAgregarBebe);
            panelPrincipal.add("Agregar Consulta", panelAgregarConsulta);     
            panelPrincipal.add("Buscar Bebe", panelBuscarBebe);
            
            UsuarioXml xml = new UsuarioXml();
            xml.GuardarUsuario(usuario);
            
        }else{
            JOptionPane.showMessageDialog(null,"Credenciales Invalidas!","Mensaje",
JOptionPane.ERROR_MESSAGE);
        }
        
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * Metodo que toma el evento click del boton
     * agregar nuevo bebe
     * @param evt 
     */
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        
        try {
            GregorianCalendar gcal = new GregorianCalendar();
            XMLGregorianCalendar fec;
            fec = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);

            String fecha_actual = this.fechaNacimientoBebe.getText();
            String[] fec_part = fecha_actual.split("/");
            fec.setYear(Integer.parseInt(fec_part[2]));
            fec.setMonth(Integer.parseInt(fec_part[1]));
            fec.setDay(Integer.parseInt(fec_part[0]));


            Bebe bebe = new Bebe();
            bebe.setApellido(this.apellidoBebe.getText());
            bebe.setCedulaPapa(this.cedulaPapa.getText());
            bebe.setFechaNacimiento(fec);
            bebe.setNombre(this.nombreBebe.getText());
            int id = agregarBebe(bebe);
            if(id != -1){
                lista = obtenerBebes(null);
                this.pacientes.removeAllItems();
                bebe.setId(id + "");
                BebeXml xml = new BebeXml();
                xml.AgregarBebe(bebe);
                for(int i = 0; i < lista.size(); i ++){
                    pacientes.addItem(lista.get(i).getNombre() + " " + lista.get(i).getApellido());
                }
            }
        } catch (DatatypeConfigurationException ex) {
            Logger.getLogger(Operaciones.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * Metodo que se encarga del evento click del boton aceptar para agregar
     * consulta
     * @param evt 
     */
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            // TODO add your handling code here:GregorianCalendar gcal = new GregorianCalendar();
            
            GregorianCalendar gcal = new GregorianCalendar();
            XMLGregorianCalendar fec;
            fec = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);

            SimpleDateFormat sdf=new java.text.SimpleDateFormat("dd/MM/yyyy");
            String fecha_actual = sdf.format(new Date());
            String[] fec_part = fecha_actual.split("/");
            fec.setYear(Integer.parseInt(fec_part[2]));
            fec.setMonth(Integer.parseInt(fec_part[1]));
            fec.setDay(Integer.parseInt(fec_part[0]));
            Consulta consulta = new Consulta();
            Proxy.Consulta.Bebe bebe = new Proxy.Consulta.Bebe();
            int pos = pacientes.getSelectedIndex();
            bebe.setApellido(lista.get(pos).getApellido());
            bebe.setCedulaPapa(lista.get(pos).getCedulaPapa());
            bebe.setFechaNacimiento(lista.get(pos).getFechaNacimiento());
            bebe.setId(lista.get(pos).getId());
            bebe.setNombre(lista.get(pos).getNombre());
            
            consulta.setEstatura(Integer.parseInt(this.estaturaPaciente.getText()));
            consulta.setPeso(Integer.parseInt(this.pesoPaciente.getText()));
            consulta.setPaciente(bebe);
            consulta.setFechaConsulta(fec);
            consulta.setCircuferencia(Integer.parseInt(this.circuferenciaCefalica.getText()));
            
            if(agregarConsulta(consulta)){
                JOptionPane.showMessageDialog(null,"Se ha agregado el bebe con exito!","Mensaje",
JOptionPane.ERROR_MESSAGE);
                ConsultaXml xmlc = new ConsultaXml();
                xmlc.AgregarConsulta(consulta);
                BebeXml xml = new BebeXml();
                if(xml.ExisteBebe(lista.get(pos)))
                    JOptionPane.showMessageDialog(null,"Existe el carajo","Mensaje",
JOptionPane.ERROR_MESSAGE);
            }
            else
                JOptionPane.showMessageDialog(null,"No Se pudo Agregar el Bebe!","Mensaje",
JOptionPane.ERROR_MESSAGE);
        } catch (DatatypeConfigurationException ex) {
            Logger.getLogger(Operaciones.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_jButton4ActionPerformed

    private void panelPrincipalFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_panelPrincipalFocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_panelPrincipalFocusGained

    private void panelAgregarConsultaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_panelAgregarConsultaFocusGained
        
    }//GEN-LAST:event_panelAgregarConsultaFocusGained

    private void panelPrincipalComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_panelPrincipalComponentMoved
       
    }//GEN-LAST:event_panelPrincipalComponentMoved

    private void panelPrincipalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_panelPrincipalStateChanged
       
    }//GEN-LAST:event_panelPrincipalStateChanged

    /**
     * Metodo que se encarga del evento click del boton aceptar para buscar los
     * datos de los bebe
     * consulta
     * @param evt 
     */
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        DefaultTableModel modelo = new DefaultTableModel();
        modelo.addColumn("Nombre");
        modelo.addColumn("Fecha Nacimiento");
        modelo.addColumn("Cedula Representante");
        tablaBebe.removeAll();
        Bebe consulta = new Bebe();
        consulta.setApellido(apellidoBusqueda.getText());
        consulta.setNombre(nombreBusqueda.getText());
        consulta.setCedulaPapa(cedulaBusqueda.getText());
        busqueda = ObtenerBebe(consulta);
        if(busqueda.size() > 0 )
            panelListaBusquedaBebe.setVisible(true);
        else 
            panelListaBusquedaBebe.setVisible(false);
        apellidoBusqueda.setText("");
        nombreBusqueda.setText("");
        cedulaBusqueda.setText("");
        for(Bebe bebe : busqueda){
              Object[] datos = new Object[3];
              datos[0] = bebe.getNombre() + " " + bebe.getApellido();
              datos[1] = bebe.getFechaNacimiento().getDay() + "/" + 
                      bebe.getFechaNacimiento().getMonth() + "/" + 
                      bebe.getFechaNacimiento().getYear();
              datos[2] = bebe.getCedulaPapa();
              modelo.addRow(datos);
        }
        tablaBebe.setModel(modelo);
    }//GEN-LAST:event_jButton6ActionPerformed

    /**
     * Metodo que se encarga del evento click del boton aceptar para editar los datos
     * de un bebe
     * consulta
     * @param evt 
     */
    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        try {
            GregorianCalendar gcal = new GregorianCalendar();
            XMLGregorianCalendar fec;
            fec = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);

            String fecha_actual = this.fechaNacimientoBebeEditar.getText();
            String[] fec_part = fecha_actual.split("/");
            fec.setYear(Integer.parseInt(fec_part[2]));
            fec.setMonth(Integer.parseInt(fec_part[1]));
            fec.setDay(Integer.parseInt(fec_part[0]));


            bebeEditar.setApellido(this.apellidoBebeEditar.getText());
            bebeEditar.setCedulaPapa(this.cedulaPapaEditar.getText());
            bebeEditar.setFechaNacimiento(fec);
            bebeEditar.setNombre(this.nombreBebeEditar.getText());
            if(editarBebe(bebeEditar)){
                JOptionPane.showMessageDialog(null,"Se ha editado el bebe con exito!","Mensaje",
JOptionPane.ERROR_MESSAGE);
                lista = obtenerBebes(null);
                this.pacientes.removeAllItems();
                for(int i = 0; i < lista.size(); i ++){
                    pacientes.addItem(lista.get(i).getNombre() + " " + lista.get(i).getApellido());
                }
                panelPrincipal.remove(panelEditarBebe);
                panelPrincipal.add("Buscar Bebe", panelBuscarBebe);
            }
        } catch (DatatypeConfigurationException ex) {
            Logger.getLogger(Operaciones.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    /**
     * Metodo que se encarga del evento click del boton editar para cargar
     * los datos del bebe seleccionado para editar
     * consulta
     * @param evt 
     */
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        
        bebeEditar = busqueda.get(tablaBebe.getSelectedRow());
        panelPrincipal.remove(panelBuscarBebe);
        panelPrincipal.add("Editar Bebe", panelEditarBebe);
        panelPrincipal.setSelectedComponent(panelEditarBebe);
        nombreBebeEditar.setText(bebeEditar.getNombre());
        apellidoBebeEditar.setText(bebeEditar.getApellido());
        cedulaPapaEditar.setText(bebeEditar.getCedulaPapa());
        fechaNacimientoBebeEditar.setText(bebeEditar.getFechaNacimiento().getDay() + "/" + 
                      bebeEditar.getFechaNacimiento().getMonth() + "/" + 
                      bebeEditar.getFechaNacimiento().getYear());
        
    }//GEN-LAST:event_jButton7ActionPerformed

    /**
     * Metodo que se encarga del evento click del boton consultas para buscar
     * todos las consultas de un bebe
     * consulta
     * @param evt 
     */
    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        bebeEditar = busqueda.get(tablaBebe.getSelectedRow());
        panelPrincipal.remove(panelBuscarBebe);
        panelPrincipal.add("Consultas Bebe", panelConsultasBebe);
        panelPrincipal.setSelectedComponent(panelConsultasBebe);
        DefaultTableModel modelo = new DefaultTableModel();
        modelo.addColumn("Fecha Evaluación");
        modelo.addColumn("Edad del Bebe");
        modelo.addColumn("Peso (Kg)");
        modelo.addColumn("Estatura (cm)");
        modelo.addColumn("Circunferencia Cefálica (cm)");
        tablaReporte.removeAll();
        Proxy.Consulta.Bebe consulta = new Proxy.Consulta.Bebe();
        Bebe bebe = busqueda.get(tablaBebe.getSelectedRow());
        consulta.setId(bebe.getId());
        lbFechaNacimiento.setText(bebe.getFechaNacimiento().getDay() + "/" + 
                      bebe.getFechaNacimiento().getMonth() + "/" + 
                      bebe.getFechaNacimiento().getYear());
        lbNombrePaciente.setText(bebe.getNombre()+ " " + bebe.getApellido());
        List<Consulta> busquedaConsultas = obtenerConsultas(consulta);
        for(Consulta cons : busquedaConsultas){
              Object[] datos = new Object[5];
              datos[0] = cons.getFechaConsulta().getDay() + "/" + 
                      cons.getFechaConsulta().getMonth() + "/" + 
                      cons.getFechaConsulta().getYear();
              Date fechaConsulta = new Date(cons.getFechaConsulta().getYear(), cons.getFechaConsulta().getMonth(),
                      cons.getFechaConsulta().getDay());
              fechaConsulta.setYear(cons.getFechaConsulta().getYear());
              Date edadBebe = new Date(bebe.getFechaNacimiento().getYear(), 
                      bebe.getFechaNacimiento().getMonth(),bebe.getFechaNacimiento().getDay());
                lbNombrePaciente.setText(bebe.getNombre()+ " " + bebe.getApellido());
              long resta = -fechaConsulta.getTime() + edadBebe.getTime();
              long meses = (long) Math.floor(resta / (1000 * 60 * 60 * 30 * 24));
              int años = (int) Math.round(meses /12);
              meses = meses - (años*12); 
              
              String edad = (años>0)? (años - 1) + " Años" : "";
              if((meses > 0) && (años > 0))
                  edad = edad + " y " + meses + " meses";
              else if((meses > 0) && (años <= 0))
                  edad = edad  + meses + " meses";
              datos[1] =   edad;
              datos[2] = cons.getPeso();
              datos[3] = cons.getEstatura();
              datos[4] = cons.getCircuferencia();
              modelo.addRow(datos);
        }
        tablaReporte.setModel(modelo);
    }//GEN-LAST:event_jButton8ActionPerformed

    /**
     * Metodo que se encarga del evento click del boton cancelar en el panel
     * de editar bebe
     * @param evt 
     */
    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        panelPrincipal.remove(panelEditarBebe);
        panelPrincipal.add("Editar Bebe", panelBuscarBebe);
        panelPrincipal.setSelectedComponent(panelBuscarBebe);
    }//GEN-LAST:event_jButton10ActionPerformed

    /**
     * Metodo que se encarga del evento click del boton regresar en el panel 
     * de las consultas
     * @param evt 
     */
    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        panelPrincipal.remove(panelConsultasBebe);
        panelPrincipal.add("Editar Bebe", panelBuscarBebe);
        panelPrincipal.setSelectedComponent(panelBuscarBebe);
    }//GEN-LAST:event_jButton11ActionPerformed
    //<editor-fold defaultstate="collapsed" desc="Varibles declaration">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField apellidoBebe;
    private javax.swing.JTextField apellidoBebeEditar;
    private javax.swing.JTextField apellidoBusqueda;
    private javax.swing.JTextField cedulaBusqueda;
    private javax.swing.JTextField cedulaPapa;
    private javax.swing.JTextField cedulaPapaEditar;
    private javax.swing.JTextField circuferenciaCefalica;
    private javax.swing.JTextField estaturaPaciente;
    private javax.swing.JTextField fechaNacimientoBebe;
    private javax.swing.JTextField fechaNacimientoBebeEditar;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lbFechaNacimiento;
    private javax.swing.JLabel lbNombrePaciente;
    private javax.swing.JTextField login;
    private javax.swing.JTextField nombreBebe;
    private javax.swing.JTextField nombreBebeEditar;
    private javax.swing.JTextField nombreBusqueda;
    private javax.swing.JComboBox pacientes;
    private javax.swing.JPanel panelAgregarBebe;
    private javax.swing.JPanel panelAgregarConsulta;
    private javax.swing.JPanel panelBuscarBebe;
    private javax.swing.JPanel panelConsultasBebe;
    private javax.swing.JPanel panelEditarBebe;
    private javax.swing.JPanel panelIngresar;
    private javax.swing.JPanel panelListaBusquedaBebe;
    private javax.swing.JTabbedPane panelPrincipal;
    private javax.swing.JPasswordField password;
    private javax.swing.JTextField pesoPaciente;
    private javax.swing.JTable tablaBebe;
    private javax.swing.JTable tablaReporte;
    // End of variables declaration//GEN-END:variables
//</editor-fold>
    
    /**
     * Metodo que crea una lista de bebe apartir de la lista cargada inicialmente
     * dado unos parametros
     * @param consulta
     * @return 
     */
    private static List<Bebe> ObtenerBebe(Bebe consulta){
        List<Bebe> retorno = new ArrayList<Bebe>();
        boolean agregado = false;
        for (Bebe elemento : lista) {
                
            if(consulta == null)
                retorno.add(elemento);
            else if((!"".equals(consulta.getNombre()))&& elemento.getNombre().
                    equalsIgnoreCase(consulta.getNombre()) && !agregado){
                retorno.add(elemento);
                agregado = true;
            }
            else if((!"".equals(consulta.getApellido()))&& elemento.getApellido().
                    equalsIgnoreCase(consulta.getApellido()) && !agregado){
                retorno.add(elemento);
                agregado = true;
            }
            else if((!"".equals(consulta.getCedulaPapa()))&& elemento.getCedulaPapa().
                    equalsIgnoreCase(consulta.getCedulaPapa()) && !agregado){
                retorno.add(elemento);
                agregado = true;
            }
            agregado = false;
        }
        return retorno;
    }
    
    /**
     * Metodo que realiza la llamada al servicio web que verifica las credenciales
     * de un usuario
     * @param usuario
     * @return 
     */
    private static boolean validarCredenciales(Proxy.Usuarios.Usuario usuario) {
        boolean retorno;
        try {
            
            Proxy.Usuarios.WsUsuario_Service service = new Proxy.Usuarios.WsUsuario_Service();
            Proxy.Usuarios.WsUsuario port = service.getWsUsuarioPort();
            retorno = port.validarCredenciales(usuario);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"No hay conexión con el servidor Central"
                    + "La Data que vera es la registrada localmente","Mensaje",
JOptionPane.ERROR_MESSAGE);
            UsuarioXml xml = new UsuarioXml();
            retorno = xml.ValidarUsuario(usuario);
        }
        return retorno;
    }

    /**
     * Metodo que realiza la llamada al web service que agrega los datos de un bebe
     * @param bebe
     * @return 
     */
    private static int agregarBebe(Proxy.WsBebe.Bebe bebe) {
        int retorno;
        try {
            
        Proxy.WsBebe.WsBebe_Service service = new Proxy.WsBebe.WsBebe_Service();
        Proxy.WsBebe.WsBebe port = service.getWsBebePort();
        retorno = port.agregarBebe(bebe);
        } catch (Exception e) {
            retorno = -1;
        }
        return retorno;
    }

    /**
     * Metodo que realiza la llamada al web service que agrega los datos de una 
     * Consulta
     * @param consulta
     * @return 
     */
    private static boolean agregarConsulta(Proxy.Consulta.Consulta consulta) {
        boolean retorno;
        try {
            
            Proxy.Consulta.WsConsulta_Service service = new Proxy.Consulta.WsConsulta_Service();
            Proxy.Consulta.WsConsulta port = service.getWsConsultaPort();
            retorno = port.agregarConsulta(consulta);
        } catch (Exception e) {
            retorno = false;
        }
        return retorno;
    }

    /**
     * Metodo que Obtiene todos los bebes registrados en el servidor
     * @return 
     */
    private static java.util.List<Proxy.WsBebe.Bebe> obtenerBebes(Bebe bebe) {
        List<Bebe> retorno;
        try {
            
            Proxy.WsBebe.WsBebe_Service service = new Proxy.WsBebe.WsBebe_Service();
            Proxy.WsBebe.WsBebe port = service.getWsBebePort();
            retorno = port.obtenerBebes(bebe);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"No hay conexión con el servidor Central"
                    + "La Data que vera es la registrada localmente","Mensaje",
JOptionPane.ERROR_MESSAGE);
            BebeXml xml = new BebeXml();
            retorno = xml.ObtenerBebes(bebe);
        }
        return retorno;
    }

    /**
     * Metodo que realiza la llamada al web service que editar los datos de una 
     * bebe
     * @param consulta
     * @return 
     */
    private static boolean editarBebe(Proxy.WsBebe.Bebe bebe) {
        boolean retorno;
        try {
            Proxy.WsBebe.WsBebe_Service service = new Proxy.WsBebe.WsBebe_Service();
            Proxy.WsBebe.WsBebe port = service.getWsBebePort();
            retorno = port.editarBebe(bebe);
            
        } catch (Exception e) {
            retorno = false;
        }
        return retorno;
    }

    /**
     * Metodo que realiza la llamada al web service que obtiene todas las consultas
     * de un bebe dado
     * @param consulta
     * @return 
     */
    private static java.util.List<Proxy.Consulta.Consulta> obtenerConsultas(Proxy.Consulta.Bebe bebe) {
        List<Consulta> retorno;
        try {
            
        Proxy.Consulta.WsConsulta_Service service = new Proxy.Consulta.WsConsulta_Service();
        Proxy.Consulta.WsConsulta port = service.getWsConsultaPort();
        retorno = port.obtenerConsultas(bebe);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"No hay conexión con el servidor Central"
                    + "La Data que vera es la registrada localmente","Mensaje",
JOptionPane.ERROR_MESSAGE);
            ConsultaXml xml = new ConsultaXml();
            retorno = xml.ObtenerConsulta(bebe);
        }
        return retorno;
    }
}
